<?php
$this->breadcrumbs = array(
    'Category' => array('index'),
    'create',
);
?>
<div class="box">
    <header>
        <h5>Create Category</h5>
    </header>
    <div class="body">
	<?php
	$form = $this->beginWidget('CActiveForm', array(
	    'htmlOptions' => array(
		'class' => 'form-horizontal',
		'enctype' => "multipart/form-data"
	)));
	?>
	<?php if ($form->errorSummary($model)) { ?>
    	<div class='alert alert-danger'>
		<?php echo $form->errorSummary($model); ?>
    	</div>
	<?php } ?>
	<?php if ($success) { ?>
    	<div class='alert alert-success'>
    	    You have updated successfully.
    	</div>
	<?php } ?>
	<fieldset>

	    <legend><span></span><h2 id="portfolioHeading">Add your category Details</h2></legend>

	    <div class="control-group">				
		<label for="inputEmail" class="control-label">Name <span>*</span></label>
		<div class="controls">
		    <?php echo $form->textField($model, 'name'); ?>
		</div>
	    </div>

	    <div class="control-group">				
		<label for="inputEmail" class="control-label">Check this, if you want to create parent category</label>
		<div class="controls">
		    <input type="checkbox" class="has_parent" name="has_parent"/>
		</div>

	    </div>

	    <div class="control-group parent-cat-admin">				
		<label for="inputEmail" class="control-label">Parent category <span>*</span></label>
		<div class="controls">
		    <?php echo $form->dropDownList($model, 'parent_id', $aParentCategories, array('class' => 'select-in-admin')); ?>
		</div>
	    </div>

	    <div class="control-group">				
		<label for="inputEmail" class="control-label">Image<span>*</span></label>
		<div class="controls">		    
		    <input type='file' name='icon' accept="image/*"/>
		</div>
	    </div>  
	    <div class="control-group">				
		<label for="inputEmail" class="control-label">Description<span>*</span></label>
		<div class="controls">
		    <?php echo $form->textArea($model, 'description', array('class' => 'input-in-admin')); ?>
		</div>
	    </div>  	    
	</fieldset>

	<div class="control-group">
	    <div class="controls">
		<input type="submit" class="btn btn-large btn-info" value="Add" name='submit'/>    			    
	    </div>
	</div>

	<?php $this->endWidget(); ?>
    </div>
</div>
<script>
    $(document).ready(function() {
	$('.has_parent').click(function() {
	    if ($(this).attr('checked')) {
		$('.parent-cat-admin').hide();
	    } else {
		$('.parent-cat-admin').show();
	    }
	});
    });
</script>